import request from '@/utils/request'
const Menu = `/system/menu`

const api = {
  getMenuList: `${Menu}/list`,
  editMenuById: `${Menu}/edit`,
  addMenu: `${Menu}/add`,
  deleteMenuByIds: `${Menu}/delete`,
  getMenuMap: `${Menu}/getMenuMap`,
  getMenuByRoleId: `${Menu}/getMenuByRoleId`,
}

export function deleteMenuByIds(parameter) {
  return request({
    url: api.deleteMenuByIds,
    method: 'get',
    params: parameter,
  })
}

/**
 * 获取所有角色
 * @param {*} parameter
 * @returns
 */
export function getMenuMap(parameter) {
  return request({
    url: api.getMenuMap,
    method: 'get',
    params: parameter,
  })
}

export function getMenuList(parameter) {
  return request({
    url: api.getMenuList,
    method: 'post',
    data: parameter,
  })
}

/**
 * 修改菜单
 * @param {*} parameter
 * @returns
 */
export function addMenu(parameter) {
  return request({
    url: api.addMenu,
    method: 'post',
    data: parameter,
  })
}

/**
 * 新增菜单
 * @param {*} parameter
 * @returns
 */
export function editMenuById(parameter) {
  return request({
    url: api.editMenuById,
    method: 'post',
    data: parameter,
  })
}

/**
 * 根据角色获取菜单
 * @param {*} parameter
 * @returns
 */
export function getMenuByRoleId(parameter) {
  return request({
    url: api.getMenuByRoleId,
    method: 'get',
    params: parameter,
  })
}
